package com.ruoyi.web.controller.base;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.base.BaseSerialNumber;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IBaseSerialNumberService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流水号规则Controller
 *
 * @author ruoyi
 * @date 2023-02-16
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/base/number" )
public class BaseSerialNumberController extends BaseController {

    private final IBaseSerialNumberService iBaseSerialNumberService;

    @ApiOperation(value = "根据单据前缀按日期生成流水号")
    @RequestMapping(value = "/take/{prefix}", method = RequestMethod.GET)
    public String getSerialNumber(@PathVariable String prefix) {
        return iBaseSerialNumberService.getSerialNumber(prefix);
    }

    @ApiOperation(value = "根据单据前缀生成流水号")
    @RequestMapping(value = "/take/{prefix}/{length}", method = RequestMethod.GET)
    public String getShortSerialNumber(@PathVariable String prefix, @PathVariable Integer length) {
        return iBaseSerialNumberService.getSerialNumber(prefix, length);
    }


}
